﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EntrustSettings.aspx.cs"
    Inherits="Thksoft.Module.ParameterSettings.EntrustSettings" %>

<!DOCTYPE html>
<html class="L_UI">
<head id="Head1" runat="server">
    <title>委托设置</title>
    <script src="/Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.7.min.js" type="text/javascript"></script>
    <script type="text/javascript">

        var option = {};
        option.CancelCallback = function (index, layero) {
            //刷新页面
            //location.href = location.href;
            $("#btnQuery").click();
        };

        function ENTRUST_CLICK(obj) {
            var key = $(obj).attr("data-id");
            var staus = $(obj).attr("data-staus");
            //弹出确定按钮
            var option = {};
            option.Type = "confirm";
            //option.Title="提示"
            if (staus == "0") {
                option.Msg = "你确定解除委托？"
            }
            else {
                option.Msg = "你确定绑定委托？"
            }
            option.YesCallback = function () {
                $("#CHECK_ID").val(key + "|" + staus);
                $("#ENTRUST_BTN").click();
            }
            top.MessageBox.Show(option);
        }
        //删除事件
        function DELETE_CLICK() {
            var checks = GET_CHECKS();
            if (checks.length == 0) {
                top.MessageBox.Alert("请至少选中一项");
            }
            else {
                //弹出确定按钮
                var option = {};
                option.Type = "confirm";
                //option.Title="提示"
                option.Msg = "你确定删除委托（共" + checks.length + "项）？"
                option.YesCallback = function () {
                    var str = "";
                    for (var i = 0; i < checks.length; i++) {
                        str += checks[i].Key;
                        if (i + 1 != checks.length) {
                            str += ",";
                        }
                    }
                    $("#DELETE_CHECK_IDS").val(str);
                    $("#ENTRUST_DELETE_BTN").click();
                }
                top.MessageBox.Show(option);
            }
        }
        //编辑事件
        function EDIT_CLICK() {
            var checks = GET_CHECKS();
            if (checks.length == 0) {
                top.MessageBox.Alert("请至少选中一项");
                return;
            }
            if (checks.length > 1) {
                top.MessageBox.Alert("只能选择一项");
                return;
            }
            var option = {};
            option.Type = "confirm";
            option.YesCallback = function (index, dom) {
                option.Title = "编辑委托";
                option.Area = ["818px", "500px"];
                option.Url = "/Module/ParameterSettings/EditEntrust.aspx?IF_EDIT=TRUE&ID=" + checks[0].Key;
                //Tools.Module.js中右上角关闭按钮触发的回调
                option.CancelCallback = function () {
                    location.href = location.href;
                };
                top.MessageBox.Load(option)
                /*document.getElementById('btnEdit').click();*/
                top.layer.close(index);
            };
            option.Msg = "确定修改?";
            top.MessageBox.Show(option);
        }
        //新增事件
        function INSERT_CLICK() {
            var option = {};
            option.Title = "新增委托";
            option.Area = ["806px", "474px"];
            option.Url = "/Module/ParameterSettings/EditEntrust.aspx?IF_EDIT=FALSE"; //"/Modal/EditEntrust.aspx?IF_EDIT=FALSE";
            option.CancelCallback = function () {
                location.href = location.href;
            };
            top.MessageBox.Load(option);
        }
        //选择所有
        function CHECKALL_CLICK() {
            $("#grvShow td :checkbox").attr('checked', 'true');
        }
        //获取选中的项 （类型对象数组,Item Key 选中项的主键）
        function GET_CHECKS() {
            var data = [];
            $("#grvShow td :checkbox").each(function () {
                if ($(this).is(":checked")) {
                    var key = $(this).attr("data-id");
                    data.push({ Key: key });
                }
            })
            return data;
        }
    </script>
</head>
<body class="bgcss">
    <form id="form1" runat="server">
        <asp:Button runat="server" ID="ENTRUST_DELETE_BTN" OnClick="DELETE_CLICK" CssClass="hide" />
        <asp:HiddenField runat="server" ID="DELETE_CHECK_IDS" />
        <asp:Button runat="server" ID="ENTRUST_BTN" OnClick="ENTRUST_CLICK" CssClass="hide" />
        <asp:HiddenField runat="server" ID="CHECK_ID" />
        <div class="Window" style="min-width: 1400px;">
            <div class="Header" style="height: 89px;">
                <table border="0" cellpadding="0" cellspacing="0" width="100%" class="table">
                    <tr>
                        <td style="width: 7%; text-align: right; padding-right: 5px;">
                            <span>关键字:</span>
                        </td>
                        <td align="left" colspan="2" style="padding-left: 10px;">
                            <asp:TextBox ID="txtKey" CssClass="txt_input" Width="150px" TabIndex="3" runat="server"
                                Height="19px"></asp:TextBox>
                            <input type="radio" id="rdbYes" name="rdb" runat="server" />委托人
                        <input id="rdbNo" type="radio" name="rdb" runat="server" />
                            被委托人
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" align="center">
                            <asp:Button ID="btnQuery" runat="server" TabIndex="4" Text="查询" CssClass="bt_css_s"
                                OnClick="btnQuery_Click" />
                            &nbsp; &nbsp;
                        <input type="button" class="bt_css_s" value="新增" onclick="INSERT_CLICK()" />
                            &nbsp;&nbsp;
                        <input type="button" class="bt_css_s" value="编辑" onclick="EDIT_CLICK()" />&nbsp;&nbsp;
                        <input type="button" class="bt_css_s" value="删除" onclick="DELETE_CLICK()" onclientclick="return confirm('确认删除?');" />
                        </td>
                    </tr>
                </table>
            </div>
            <div class="Content" style="top: 70px; overflow-y: auto;">
                <div class="Pg-Content">
                    <asp:ScriptManager ID="ScriptManagers" runat="server" EnablePageMethods="True" EnableScriptGlobalization="True"
                        EnableScriptLocalization="True">
                    </asp:ScriptManager>
                    <asp:Panel ID="Panel1" runat="server">
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
                                <asp:GridView ID="grvShow" runat="server" AutoGenerateColumns="False" CssClass="cont_list zebra"
                                    Width="100%" EmptyDataText="没有查找到您要的数据" AllowSorting="True" OnSorting="grvShow_Sorting">
                                    <Columns>
                                        <asp:TemplateField>
                                            <HeaderTemplate>
                                                <input type="checkbox" onclick="CHECKALL_CLICK()" />
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <input type="checkbox" data-id="<%#Eval("N_ENTRUST_ID")%>" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField HeaderText="编号" DataField="N_ENTRUST_ID" SortExpression="N_ENTRUST_ID" />
                                        <asp:BoundField HeaderText="委托人" DataField="ENTRUST_USER_NAME" SortExpression="ENTRUST_USER_NAME" />
                                        <asp:BoundField HeaderText="被委托人" DataField="USER_NAME" SortExpression="USER_NAME" />
                                        <asp:BoundField HeaderText="开始时间" DataField="D_NTRUST_START_DATE" SortExpression="D_NTRUST_START_DATE" />
                                        <asp:BoundField HeaderText="结束时间" DataField="D_NTRUST_ENDDATA" SortExpression="D_NTRUST_ENDDATA" />
                                        <asp:TemplateField HeaderText="委托状态">
                                            <ItemTemplate>
                                                <input data-id="<%#Eval("N_ENTRUST_ID")%>" data-staus="<%#Eval("C_ENTRUST_STATE")%>"
                                                    onclick="ENTRUST_CLICK(this)" type="button" value="<%#Eval("C_ENTRUST_STATE").ToString()=="0"?"委托":"取消"%>" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </asp:Panel>
                </div>
            </div>
            <div class="Pg">
                <uc1:Pagination ID="PageIng" runat="server" IsDataBindOnLoad="false" OnDataBinding="PageIng_DataBinding"
                    Visible="false" />
            </div>
        </div>
    </form>
</body>
</html>